$(document).ready(function () {
    let id = getUrlString("id");
    let obj = new Object();
    obj.m= "getMerchantById";
    obj.id= 1;

    $.ajax({
        //请求方式： 同步 false 异步 true
        async:true,
        //请求方式
        type:"POST",
        //请求地址
        url:basePath2+"/api/merchandise",
        //数据 ,json字符串
        //返回值的类型
        dataType:"json",
        data:obj,
        //请求成功
        success:function (result) {
            initMerchantInfo(result);
        },
        //请求失败
        error:function (e) {
            console.log(e.status);
            console.log(e.responseText);
        }
    });
});

function initMerchantInfo(result) {
    console.log(result);
    $(".detail").html("");//清空
    let img=$("<img>").attr("src","/resources"+result.picture);
    let span1=$("<span></span>").text("商品类别："+result.category);
    let br1 = $("<br>");
    let span2=$("<span></span>").text("商品名称："+result.merName);
    let br2 = $("<br>");
    let span3=$("<span></span>").text("商品型号："+result.merModel);
    let br3 = $("<br>");
    let span4=$("<span></span>").text("市场价：￥"+result.price);
    let br4 = $("<br>");
    let span5=null;
    let br5=null;
    let span6=$("<span></span>").text("生产厂家："+result.manufacturer);
    let br6 = $("<br>");
    let span7=$("<span></span>").text("出厂日期："+result.leaveFactoryDate);
    let br7 = $("<br>");
    let span8=$("<span></span>").text("出厂日期："+result.merDesc);
    if (result.sprice==1){
        let span5=$("<span></span>").text("特价：￥"+result.sprice);
        let br5 = $("<br>");
    }
    $(".detail").append(img,span1,br1,span2,br2,span3,br3,span4,br4,span5,br5,span6,br6,span7,br7,span8);
}